from django.db import models
from django.utils import timezone


class InvolverInfo(models.Model):
    db_id = models.AutoField(primary_key=True)
    id = models.CharField(max_length=40, blank=True, null=True)
    name = models.CharField(max_length=100, blank=True, null=True)
    mobile = models.CharField(max_length=40, blank=True, null=True)
    sex = models.CharField(max_length=10, blank=True, null=True)
    birthday = models.DateField(blank=True, null=True)
    document_type = models.CharField(max_length=100, blank=True, null=True)
    document_number = models.CharField(max_length=50, blank=True, null=True)
    car_number = models.CharField(max_length=100, blank=True, null=True)
    house_address = models.CharField(max_length=250, blank=True, null=True)
    address = models.TextField(blank=True, null=True)
    province_name = models.CharField(max_length=20, blank=True, null=True)
    province_id = models.CharField(max_length=20, blank=True, null=True)
    city_name = models.CharField(max_length=20, blank=True, null=True)
    city_id = models.CharField(max_length=20, blank=True, null=True)
    area_name = models.CharField(max_length=20, blank=True, null=True)
    area_id = models.CharField(max_length=20, blank=True, null=True)
    feedback_name = models.CharField(max_length=40, blank=True, null=True)
    feedback_phone = models.CharField(max_length=40, blank=True, null=True)
    status = models.IntegerField(default=0)
    create_time = models.DateTimeField(auto_now_add=True)
    modify_time = models.DateTimeField(auto_now=True)
    remark = models.TextField(blank=True, null=True)
    delete_flag = models.BooleanField(default=False)

    class Meta:
        db_table = 'involver_info'


class MigrantsInfo(models.Model):
    name = models.CharField(max_length=100, blank=True, null=True, verbose_name="姓名")
    mobile = models.CharField(max_length=40, blank=True, null=True, verbose_name="手机号")
    document_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="证件类型")
    document_number = models.CharField(max_length=50, blank=True, null=True, verbose_name="证件号码")
    ways = models.CharField(max_length=100, blank=True, null=True, verbose_name="出行方式")
    car_number = models.CharField(verbose_name="车牌号", max_length=100, blank=True, null=True)
    from_province_id = models.IntegerField(blank=True, null=True)
    from_city_id = models.IntegerField(blank=True, null=True)
    from_area_id = models.IntegerField(blank=True, null=True)
    to_province_id = models.IntegerField(blank=True, null=True)
    to_city_id = models.IntegerField(blank=True, null=True)
    to_area_id = models.IntegerField(blank=True, null=True)
    from_label = models.CharField(null=True,blank=True, max_length=255)
    to_label = models.CharField(null=True,blank=True, max_length=255)
    detail_address = models.TextField(null=True, blank=True)
    arrival_time = models.DateField(verbose_name="预计到达时间")
    org = models.CharField(max_length=255, blank=True, null=True, verbose_name="工作单位")
    status = models.IntegerField(default=0)
    symptom = models.CharField(max_length=255, null=True, blank=True, verbose_name="体测情况")
    condition = models.BooleanField(default=False)
    create_time = models.DateTimeField(auto_now_add=True)
    modify_time = models.DateTimeField(auto_now=True)
    remark = models.TextField(blank=True, null=True, verbose_name="备注")
    delete_flag = models.BooleanField(default=False)

    class Meta:
        db_table = 'migrants_info'


class Party(models.Model):
    name = models.CharField(max_length=100, blank=True, null=True, verbose_name="姓名")
    mobile = models.CharField(max_length=40, blank=True, null=True, verbose_name="手机号")
    document_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="证件类型")
    document_number = models.CharField(max_length=50, blank=True, null=True, verbose_name="身份证号码")
    from_province_id = models.IntegerField(blank=True, null=True)
    from_city_id = models.IntegerField(blank=True, null=True)
    from_area_id = models.IntegerField(blank=True, null=True)
    to_province_id = models.IntegerField(blank=True, null=True)
    to_city_id = models.IntegerField(blank=True, null=True)
    to_area_id = models.IntegerField(blank=True, null=True)
    detail_address = models.TextField(null=True,blank=True)
    from_label = models.CharField(null=True, blank=True, max_length=255)
    to_label = models.CharField(null=True, blank=True, max_length=255)
    arrival_time = models.DateField(verbose_name="预计到达时间")
    org = models.CharField(max_length=255, blank=True, null=True, verbose_name="工作单位")
    status = models.IntegerField(default=0)
    symptom = models.CharField(max_length=255, null=True, blank=True, verbose_name="体测情况")
    condition = models.BooleanField(default=False)
    create_time = models.DateTimeField(auto_now_add=True)
    modify_time = models.DateTimeField(auto_now=True)
    remark = models.TextField(blank=True, null=True, verbose_name="备注")
    relative = models.CharField(max_length=20, null=True, blank=True)
    migrants = models.ForeignKey(MigrantsInfo, on_delete=models.CASCADE, related_name="party", null=True, blank=True)
    delete_flag = models.BooleanField(default=False)

    class Meta:
        db_table = 'party_info'

